package com.pgytesting.secondhandcar.service.impl;

import com.pgytesting.secondhandcar.model.ExamineInformation;
import com.pgytesting.secondhandcar.dao.ExamineInformationDao;
import com.pgytesting.secondhandcar.service.ExamineInformationService;
import com.pgytesting.secondhandcar.util.SessionUtil;
import com.pgytesting.secondhandcar.util.UtilMethod;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ExamineInformation)表服务实现类
 *
 * @author makejava
 * @since 2019-08-15 14:36:14
 */
@Service("examineInformationService")
public class ExamineInformationServiceImpl implements ExamineInformationService {
    @Resource
    private ExamineInformationDao examineInformationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ExamineInformation queryById(Integer id) {
        return this.examineInformationDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ExamineInformation> queryAllByLimit(int offset, int limit) {
        return this.examineInformationDao.queryAllByLimit(offset, limit);
    }
    
    /**
     * 条件查询多条数据
     *
     * @param examineInformation 实例对象
     * @return 对象列表
     */
    @Override
    public List<ExamineInformation> queryAll(ExamineInformation examineInformation) {
        return this.examineInformationDao.queryAll(examineInformation);
    }

    /**
     * 新增数据
     *
     * @param examineInformation 实例对象
     * @return 实例对象
     */
    @Override
    public ExamineInformation insert(ExamineInformation examineInformation) {
        this.examineInformationDao.insert(examineInformation);
        return examineInformation;
    }

    /**
     * 修改数据
     *
     * @param examineInformation 实例对象
     * @return 实例对象
     */
    @Override
    public ExamineInformation update(ExamineInformation examineInformation) {
        this.examineInformationDao.update(examineInformation);
        return this.queryById(examineInformation.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.examineInformationDao.deleteById(id) > 0;
    }

	@Override
	public Integer insert(Integer state) {
		ExamineInformation examineInformation = new ExamineInformation();
		examineInformation.setState(state);
		examineInformation.setExamineUserNumber(SessionUtil.getSessionAdmin().getUserNumber());
		examineInformation.setCreatedBy(SessionUtil.getSessionAdmin().getUserNumber());
		examineInformation.setStatus(0);
		examineInformation.setExamineTime(UtilMethod.unixLong());
		examineInformation.setCreatedTime(UtilMethod.unixLong());
		
		examineInformationDao.insert(examineInformation);
		return examineInformation.getId();
	}
    
    
}